#include "frloaidaily.h"
#include "ui_frloaidaily.h"
#include "QtSql"
#include "qmessagebox.h"
#include"quanlydaily.h"
frloaidaily::frloaidaily(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::frloaidaily)
{
    ui->setupUi(this);
    db=new ketnoiDB();
}

frloaidaily::~frloaidaily()
{
    delete ui;
}

void frloaidaily::on_btbThemLoaiDaiLy_clicked()
{
    bool ok;
    ui->txtMaLoaiDaiLy->text().toInt(&ok);

    if(!ok)
    {
            QMessageBox::critical(this, "Data error", "Chưa nhập Mã Đại Lý.");

            return;
    }

    QString query ="INSERT INTO loaidaily (MaLoaiDaiLy,TenLoaiDaiLy) VALUES ('"+ui->txtMaLoaiDaiLy->text()+"','"+ui->txtTenLoaiDaiLy->text()+"')";


    db->capNhatDuLieu(query);


}
// delete from loaidaily where MaLoaiDaiLy='"ui->txtMaLoaiDaiLy->text()"'";




void frloaidaily::on_btnXoaRong_clicked()
{
    ui->txtMaLoaiDaiLy->setText("");
    ui->txtTenLoaiDaiLy->setText("");
    ui->txtMaLoaiDaiLy->setFocus();
}
